package com.peza.bikelog.gui.views;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.peza.bikelog.common.domain.LogEntry;
import com.peza.bikelog.gui.data.DateColumnGenerator;
import com.peza.bikelog.gui.data.EntryContainer;
import com.peza.bikelog.gui.data.EntryTable;
import com.peza.bikelog.gui.restclient.RestClient;
import com.peza.bikelog.gui.restclient.RestClientImpl;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;

public class TableView extends AbstractView implements Property.ValueChangeListener{

	private static Logger logger = Logger.getLogger(TableView.class);
	
	private BeanItemContainer<LogEntry> entryContainer;
	
	private Table entryTable;
	
	@Autowired
	private RestClient client = new RestClientImpl();
	
	public TableView(){
		logger.debug(client);
		entryContainer = new EntryContainer();
		entryContainer.addAll(client.findRange(101, 110));
		initGui();
		
	}
	
	private void initGui(){
		
		/** Panels and Layouts **/
		Panel trxPanel = new Panel("transactions");
		VerticalLayout trxLayout = new VerticalLayout();
		
		
		/** -----------------------------------------------------**/
		/** TRANSACTIONS panel **/
		entryTable = new EntryTable("",entryContainer);
		trxLayout.addComponent(entryTable);
		trxPanel.setContent(trxLayout);
		
			
		/** -----------------------------------------------------**/
		/** Wiring it all together **/
		this.addComponent(trxPanel);
		
	}
	
	
	
	@Override
	public void valueChange(ValueChangeEvent event) {
		// TODO Auto-generated method stub
		
	}
	
	private static final long serialVersionUID = 1L;


}
